// 2025/3/21
// https://leetcode.cn/problems/find-minimum-in-rotated-sorted-array/description/?envType=study-plan-v2&envId=top-100-liked
// 寻找旋转排序数组中的最小值

class Solution {
    public:
        int findMin(vector<int>& nums) {
            int left = 0, right = nums.size() - 1;
            if(nums[left] < nums[right]) return nums[0];
            int mid = (left + right) / 2;
            while(left <= right)
            {
                mid = (left + right) / 2;
                if(nums[mid] > nums[left])
                    left = mid;
                else if(nums[mid] < nums[right])
                    right = mid;
                else
                    break;
            }
            return min(nums[left], nums[right]);
        }
    };